﻿// <copyright file="XmlHelperTest.cs" company="Snowman Consulting">
//     Copyright (c) 2009 Snowman Consulting. All rights reserved.
// </copyright>

namespace SnowmanConsulting.ProductKeyManager.Test
{
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using SnowmanConsulting.ProductKeyManager.Data;
    using SnowmanConsulting.ProductKeyManager.Xml;    
    
    /// <summary>
    /// This is a test class for XmlHelperTest and is intended
    /// to contain all XmlHelperTest Unit Tests
    /// </summary>
    [TestClass()]
    public class XmlHelperTest
    {
        /// <summary>
        /// Test context
        /// </summary>
        private TestContext testContextInstance;

        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext
        {
            get
            {
                return this.testContextInstance;
            }

            set
            {
                this.testContextInstance = value;
            }
        }

        /// <summary>
        /// A test for Load
        /// </summary>
        [TestMethod()]
        public void ImportXmlTest()
        {
            ProductCollection expected = new ProductCollection();
            TestHelper.CreateExpectedProducts(expected);

            ProductKeyManagerXmlHandler pkmHandler = new ProductKeyManagerXmlHandler();
            pkmHandler.GenerateXml(expected);
            string generatedXml1 = pkmHandler.GeneratedXml;

            MsdnXmlHandler msdnHandler = new MsdnXmlHandler();
            msdnHandler.GenerateXml(expected);
            string generatedXml2 = msdnHandler.GeneratedXml;

            XamlHandler xamlHandler = new XamlHandler();
            xamlHandler.GenerateXml(expected);
            string generatedXml3 = xamlHandler.GeneratedXml;

            ProductKeyManagerXmlHandler expected1 = XmlHelper.Load(generatedXml1) as ProductKeyManagerXmlHandler;

            Assert.IsNotNull(expected1);

            MsdnXmlHandler expected2 = XmlHelper.Load(generatedXml2) as MsdnXmlHandler;

            Assert.IsNotNull(expected2);

            XamlHandler expected3 = XmlHelper.Load(generatedXml3) as XamlHandler;

            Assert.IsNotNull(expected3);
        }
    }
}
